;;; init-eaf.el --- configuration for emacs-application-framework -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:

(with-eval-after-load 'eaf
  (require 'eaf-pdf-viewer)
  (require 'eaf-markdown-previewer)

  ;; (setq eaf-enable-debug t)
  ;; (setq eaf-proxy-type "sockts5")
  ;; (setq eaf-proxy-host "127.0.0.1")
  ;; (setq eaf-proxy-port "1080")

  (setq eaf-find-file-advisor-enable nil)
  (setq eaf-dired-advisor-enable nil)

  (defun ctrlwei/eaf-translate-text (text)
    "Translate selected TEXT use popweb."
    (popweb-dict-bing-input text))
  (advice-add 'eaf-translate-text :override #'ctrlwei/eaf-translate-text))

(autoload 'eaf-get-theme-foreground-color "eaf" nil t)
(global-set-key (kbd "M-g f") #'eaf-open-browser-with-history)
(with-eval-after-load 'eaf-browser
  (eaf-bind-key nil "M-q" eaf-browser-keybinding)

  (setq eaf-browser-search-engines '(("baidu" . "http://www.baidu.com/s?wd=%s")
                                     ("sougo" . "https://www.sogou.com/web?query=%s")
                                     ("StackExchange" . "https://stackexchange.com/search?q=%s")
                                     ("bing" . "https://www.bing.com/search?q=%s")
                                     ("google" . "http://www.google.com/search?ie=utf-8&oe=utf-8&q=%s")))
  (setq eaf-browser-default-search-engine "baidu")
  (setq eaf-browser-dark-mode nil)
  (setq eaf-browser-enable-adblocker t)
  (setq eaf-browser-ignore-history-list '("google.com/search")))

(with-eval-after-load 'eaf-markdown-previewer
  (eaf-bind-key nil "M-q" eaf-markdown-previewer-keybinding)
  (setq eaf-markdown-dark-mode nil))

(with-eval-after-load 'eaf-pdf-viewer
  (setq eaf-pdf-dark-mode nil)
  (eaf-bind-key scroll_up_page "d" eaf-pdf-viewer-keybinding)
  (eaf-bind-key scroll_down_page "u" eaf-pdf-viewer-keybinding))

(setq browse-url-browser-function 'eaf-open-browser)
(defalias 'browse-web #'eaf-open-browser)

(provide 'init-eaf)
;;; init-eaf.el ends here
